import 'package:fish_redux/fish_redux.dart';

import 'action.dart';
import 'state.dart';

Reducer<SmsLoginState> buildReducer() {
  return asReducer(
    <Object, Reducer<SmsLoginState>>{
      SmsLoginAction.loading: _onLoadingAction,
      SmsLoginAction.setRemain: _onSetRemainTextAction,
  SmsLoginAction.setSmsId: _onSetSmsIdAction,
    },
  );
}

SmsLoginState _onLoadingAction(SmsLoginState state, Action action) {
  final SmsLoginState newState = state.clone();
  newState.isLoading = action.payload;
  return newState;
}
SmsLoginState _onSetRemainTextAction(SmsLoginState state, Action action) {
  final SmsLoginState newState = state.clone();
  newState.remainSeconds = action.payload;
  return newState;
}
SmsLoginState _onSetSmsIdAction(SmsLoginState state, Action action) {
  final SmsLoginState newState = state.clone();
  newState.smsId = action.payload;
  return newState;
}
